package ru.xpparty.scanner.model;

import ru.xpparty.scanner.PortRange;

/**
 * Mofel class to host, which contains range ip and ports.
 */
public class ScanRequest {
    private final String ip;
    private PortRange portRange;

    public ScanRequest(String host, PortRange portRange) {
        ip = host;
        this.portRange = portRange;
    }

    public String getHost() {
        return ip;
    }

    public int getFrom() {
        return portRange.getStart();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ScanRequest scanRequest = (ScanRequest) o;

        if (portRange.getStart() != scanRequest.getFrom()) return false;
        if (portRange.getEnd() != scanRequest.getTo()) return false;
        if (!ip.equals(scanRequest.ip)) return false;

        return true;
    }


    public int getTo() {
        return portRange.getEnd();
    }
}
